<?php

namespace app\controller;

use think\facade\Db;
use think\Request;

class Detail
{
    public function news(Request $request)
    {
        $id = str_replace('detail/news/', '', $request->pathinfo());
        if (empty($id)) {
            return json()->data(['code' => 400, 'msg' => '系统繁忙,请稍后再试']);
        } else {
            $data = Db::name('news')->find($id);
            $data['time'] = substr($data['time'], 0, 10);
            return json()->data(['code' => 200, 'data' => $data, 'msg' => '成功']);
        }
    }
}
